﻿using System;
using System.Windows.Forms;
using NGridDrawer.Partitions;
using NGridDrawer.Report.Layout;


namespace NGridDrawer.Sample.CS
{
    
    public partial class Form1 : Form
    {

        public Form1()
        {
            InitializeComponent();
            

            chkCenter.Checked = gridDrawer.MustCenterHorizontally;
            chkFitColumns.Checked = gridDrawer.MustFitColumnsToBounds;
            chkSelectedRows.Checked = gridDrawer.MustPrintSelectedRows;
            chkLevelByLevel.Checked = 
                gridDrawer.PrintOrder == PartitionOrder.OrderByLevelFirst;
            chkRowHeader.Checked = gridDrawer.MustPrintRowHeaders;
            chkPrintColumnHeaders.Checked = gridDrawer.MustPrintColumnHeaders;

            reportDrawer.Title = new BlockTitle("Document Report");
            reportDrawer.Header = new BlockHeader();
            reportDrawer.Footer = new BlockFooter();


            printPreviewDialog.WindowState = FormWindowState.Maximized;

            
        }



        protected class CustomRowHeaderCell : DataGridViewRowHeaderCell
        {
            protected override object GetValue(int rowIndex)
            {
                return (rowIndex + 1).ToString();
            }
        }


        private void Form1_Load(object sender, EventArgs e)
        {
            GridView.RowTemplate.HeaderCell = new CustomRowHeaderCell();

            customers2TableAdapter.Fill(customersDataSet.Customers2);

            GridView.Rows[1].Cells[1].ToolTipText = "hello world 1.1";
            GridView.Rows[1].Cells[2].ToolTipText = "hello world 1.2";
            GridView.Rows[2].Cells[1].ToolTipText = "hello world 1.3";
            GridView.Rows[2].Cells[2].ToolTipText = "hello world 1.4";


            GridView.Rows[1].Cells[6].ToolTipText = "hello world 2";
            GridView.Rows[50].Cells[6].ToolTipText = "hello world 2";



        }


        private void btnPrint_Click(object sender, EventArgs e)
        {
            if (printDialog.ShowDialog(this) == DialogResult.OK)
                printDocument.Print();
        }


        private void btnPreview_Click(object sender, EventArgs e)
        {
            if (printDialog.ShowDialog(this) == DialogResult.OK)
                printPreviewDialog.ShowDialog(this);
        }

        private void chkCenter_CheckedChanged(object sender, EventArgs e)
        {
            gridDrawer.MustCenterHorizontally = chkCenter.Checked;
        }

        private void chkFitColumns_CheckedChanged(object sender, EventArgs e)
        {
            gridDrawer.MustFitColumnsToBounds = chkFitColumns.Checked;
        }

        private void chkLevelByLevel_CheckedChanged(object sender, EventArgs e)
        {
            gridDrawer.PrintOrder = (chkLevelByLevel.Checked) ? 
                PartitionOrder.OrderByLevelFirst :
                PartitionOrder.OrderByColumnFirst;
        }

        private void chkSelectedRows_CheckedChanged(object sender, EventArgs e)
        {
            gridDrawer.MustPrintSelectedRows = chkSelectedRows.Checked;
        }


        private void chkRowHeader_CheckedChanged(object sender, EventArgs e)
        {
            gridDrawer.MustPrintRowHeaders = chkRowHeader.Checked;
        }

        private void chkPrintColumnHeaders_CheckedChanged(object sender, EventArgs e)
        {
            gridDrawer.MustPrintColumnHeaders = chkPrintColumnHeaders.Checked;
        }




    }



}
